package MRtest;

import org.apache.hadoop.io.Writable;

import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
import java.math.BigDecimal;

public class Bean implements Writable {

    String username,time;
    BigDecimal cost;


    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public BigDecimal getCost() {
        return cost;
    }

    public void setCost(BigDecimal cost) {
        this.cost = cost;
    }

    public String getTime() {
        return time;
    }

    public void setTime(String time) {
        this.time = time;
    }

    public Bean( String username,String time,BigDecimal cost) {
        this.username = username;
        this.time = time;
        this.cost = cost;

    }

    public Bean() {
    }

    @Override
    public void readFields(DataInput dataInput) throws IOException {
        //写出


        this.username = dataInput.readUTF();
        this.time = dataInput.readUTF();
        this.cost = new BigDecimal(dataInput.readUTF());
    }

    @Override
    public void write(DataOutput dataOutput) throws IOException {
        //写入
        dataOutput.writeUTF(username);
        dataOutput.writeUTF(time.toString());
        dataOutput.writeUTF(cost.toPlainString());
//        dataOutput.writeUTF(log_id.toString());

    }

    @Override
    public String toString() {
        return   time + "\t" + cost;
    }
}
